/*****************************************************************
          jQuery Validate扩展验证方法  (2017.08.07 - Cyan)       
*****************************************************************/

//电话号码验证    phone
jQuery.validator.addMethod("phone", function(value, element, param) { 
  var tel = /^(\d{3,4}-?)?\d{7,9}$/g;    
  return this.optional(element) || (tel.test(value));    
}, "电话号码不正确");

//手机号码的验证 mobile
$.validator.addMethod("mobile", function(value, element, param){
	var length = value.length;
  return this.optional(element) || (length == 11 && /^1[34578]\d{9}$/.test(value));
}, "手机号码不正确");

//联系电话(手机/电话皆可)验证  telPhone
$.validator.addMethod("telPhone", function(value, element, param) {
	console.log('value==='+value);
	console.log('param=='+param); 
    var length = value.length;   
    //var mobile = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/; 
    //var tel = /^(\d{3,4}-?)?\d{7,9}$/g;  
    var mobile = /^1[34578]\d{9}$/;      
    var tel = /^0\d{2,3}-?\d{7,8}$/;
    return this.optional(element) || tel.test(value) || (length==11 && mobile.test(value));   
}, "联系电话不正确"); 

//自定义正则 验证 customRegExp
jQuery.validator.addMethod("customRegExp", function(value, element, param) { 
	var reg = eval(param);
	return this.optional(element) || (reg.test(value));    
}, "输入格式不正确");

